<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>煤炭管理系统</title>
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/lib/layui/css/layui-theme-custom.css">
    <link rel="stylesheet" href="/static/css/member.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <#include "/base/main-header.ftl">

    <#include "/base/main-left.ftl">
    <div class="layui-body">
        <!-- 内容主体区域  -->
        <div class="site-title">
            <fieldset>
                <legend>
                    <a class="site-title-text">基本情况</a>
                </legend>
            </fieldset>
        </div>
        <form class="layui-form"  >
        <input type="hidden" name="purchApplyId" value="${p.purchApplyId!""}">
        <div class="table-box">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">报价截止时间：</label>
                        <div class="layui-input-inline">
                            <input type="date" name="bjEnd" lay-verify="required|date|bjAfterApply|bjBeforeJh" autocomplete="off"  value="${p.bjEnd!""}" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">申请单位：</label>
                        <div class="layui-input-inline">
                            <input type="text" disabled name="createUserOrg"   autocomplete="off"
                                   lay-verify="required"
                                   class="layui-input layui-disabled" value="${p.createUserOrg!""}">
                        </div>
                    </div>
                    <input name="createUserId" type="hidden" value="${p.createUserId!""}">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">单据编号：</label>
                        <div class="layui-input-inline">

                            <input type="text" name="billNumber" lay-verify="required"
                                   autocomplete="off" class="layui-input
                            layui-disabled" disabled value="${p.billNumber!""}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">申请人：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="${p.createUser!""}" lay-verify="required" name="createUser"   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">签发人：</label>
                        <div class="layui-input-inline">
                            <input type="text" value="${p.writerName!""}" lay-verify="required"
                                   name="writerName"   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">申请日期：</label>
                        <div class="layui-input-inline">
                            <input type="date"  value="${p.createDate!""}" name="createDate" lay-verify="required|date|applyBeforeJh"   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">交货时间：</label>
                        <div class="layui-input-inline">
                            <input type="date" value="${p.jhtime!""}" name="jhtime" lay-verify="required|date|jhnotBefore" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">至</label>
                        <div class="layui-input-inline">
                            <input type="date" value="${p.jhtimeEnd!""}" name="jhtimeEnd" lay-verify="required|date" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">煤种：</label>

                        <div class="layui-input-inline">
                            <select name="coalType">
                        <option value="烟煤" <#if p.coalType == "烟煤"> selected </#if> >烟煤</option>
                        <option value="无烟煤" <#if p.coalType == "无烟煤"> selected="" </#if> >无烟煤</option>
                        <option value="褐煤" <#if p.coalType == "褐煤"> selected="" </#if>>褐煤</option>
                        <option value="贫瘦煤" <#if p.coalType == "贫瘦煤"> selected="" </#if>>贫瘦煤</option>
                        <option value="其他" <#if p.coalType == "其他"> selected="" </#if>>其他</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                        <select name="coalClass">
                            <option value="原煤" <#if p.coalClass == "原煤"> selected="" </#if>>原煤</option>
                            <option value="混煤" <#if p.coalClass == "混煤"> selected="" </#if>>混煤</option>
                            <option value="中煤" <#if p.coalClass == "中煤"> selected="" </#if>>中煤</option>
                            <option value="煤泥" <#if p.coalClass == "煤泥"> selected="" </#if>>煤泥</option>
                            <option value="其他" <#if p.coalClass == "其他"> selected="" </#if>>其他</option>
                        </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">采购数量：</label>
                        <div class="layui-input-inline">
                            <input  value="${p.purchaseNum!""}" lay-verify="required"
                                    type="number" min="0" name="purchaseNum"  autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（万吨）</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">运输方式：</label>
                        <div class="layui-input-inline">
                            <select name="yunshuMode">
                            <option value="火车" <#if p.yunshuMode == "火车"> selected="" </#if>>火车</option>
                            <option value="汽车" <#if p.yunshuMode == "汽车"> selected="" </#if>>汽车</option>
                            <option value="船运" <#if p.yunshuMode == "船运"> selected="" </#if>>船运</option>
                            <option value="其他" <#if p.yunshuMode == "其他"> selected="" </#if>>其他</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">交货地点：</label>
                        <div class="layui-input-inline">
                            <input value="${p.jiaohuoLocation!""}" type="text" name="jiaohuoLocation" required autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">结算方式：</label>
                        <div class="layui-input-inline">
                            <select name="jiesuanMode">
                            <option value="一票结算" <#if p.jiesuanMode == "一票结算"> selected="" </#if>>一票结算</option>
                            <option value="二票结算" <#if p.jiesuanMode == "二票结算"> selected="" </#if>>二票结算</option>
                            <option value="铁路大票" <#if p.jiesuanMode == "铁路大票"> selected="" </#if>>铁路大票</option>
                            <option value="煤款税票" <#if p.jiesuanMode == "煤款税票"> selected="" </#if>>煤款税票</option>
                            <option value="其他" <#if p.jiesuanMode == "其他"> selected="" </#if>>其他</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">验收方式：</label>
                        <div class="layui-input-inline">
                            <select name="yanshouMode">
                                <option value="到厂验收" <#if p.yanshouMode == "到厂验收"> selected="" </#if>>到厂验收</option>
                                <option value="到厂第三方验收" <#if p.yanshouMode == "到厂第三方验收"> selected="" </#if>>到厂第三方验收</option>
                                <option value="港口第三方验收" <#if p.yanshouMode == "港口第三方验收"> selected="" </#if>>港口第三方验收</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">最高限价：</label>
                        <div class="layui-input-inline">
                            <input type="number" min="0" value="${p.maxLimitPrice!""}" name="maxLimitPrice" lay-verify="required|biggerPrice"  autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（元/卡.吨）</label>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">最低限价：</label>
                        <div class="layui-input-inline">
                            <input type="number" min="0"  value="${p.minLimitPrice!""}" name="minLimitPrice" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（元/卡.吨）</label>
                    </div>
                </div>
                <div class="layui-form-item">

                        <label class="layui-form-label label-width xreuired">限价说明：</label>
                        <textarea name="maxRemark"  lay-verify="required"   placeholder="请输入限价说明" style="width: 600px;" class="layui-textarea" >${p.minLimitPrice!""}</textarea>

                    </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width xreuired">结算付款方式：</label>
                        <div class="layui-input-inline">
                            <input value="${p.paymode!""}" type="text" name="paymode" required autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label label-width xreuired">报价保证金缴纳：</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="isQuotebond" lay-filter="quote"   value="0" title="不要求" <#if p.isQuotebond == 0> checked="" </#if>>
                        <input type="radio" name="isQuotebond"  lay-filter="quote"   value="1" title="要求" <#if p.isQuotebond == 1> checked="" </#if>>
                    </div>
                    <div class="layui-input-inline">
                        <input id="quote-input" type="number" value="${p.quotebondNumber!""}" name="quotebondNumber"   autocomplete="off" class="layui-input layui-disabled" disabled >
                    </div>
                    <label class="myLable">元/吨</label>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label label-width xreuired">履约保证金缴纳：</label>
                    <div class="layui-input-inline">
                        <input type="radio"  id="per-no" lay-filter="per" name="isPerformbond" value="0" title="不要求" <#if p.isPerformbond == 0> checked="" </#if>>
                        <input type="radio" id="per-yes" lay-filter="per" name="isPerformbond" value="1" title="要求" <#if p.isPerformbond == 1> checked="" </#if>>
                    </div>
                    <div class="layui-input-inline">
                        <input  id="per-input" type="number" name="performbondNumber" value="${p.performbondNumber!""}"
                                autocomplete="off" class="layui-input layui-disabled" disabled>
                    </div>
                    <label class="myLable">元/吨</label>
                </div>
        </div>
        <br>

        <div class="site-title">
            <fieldset>
                <legend>
                    <a class="site-title-text">煤质要求</a>
                </legend>
            </fieldset>
        </div>
        <div class="table-box">

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width smallTitle">收到基基准：</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">收到基低位发热量Qnet,ar≥：</label>
                        <div class="layui-input-inline">
                            <input value="${p.rec1!""}" type="number"  min="0" name="rec1" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（KCal/kg）</label>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">收到基全硫St,ar≤：</label>
                        <div class="layui-input-inline">
                            <input value="${p.rec2!""}" type="number"  min="0" name="rec2" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>

                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">全水分M≤：</label>
                        <div class="layui-input-inline">
                            <input type="number" value="${p.rec3!""}"  min="0" name="rec3" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">收到基灰分Aar≤：</label>
                        <div class="layui-input-inline">
                            <input type="number" value="${p.rec4!""}"  min="0" name="rec4" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label label-width">收到基挥发分Var：</label>
                        <div class="layui-input-inline">
                            <input type="number" value="${p.rec51!""}" min="0" name="rec51" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）至</label>
                        <div class="layui-input-inline">
                            <input type="number" value="${p.rec52!""}"  lay-verify="biggerRec" min="0" name="rec52" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>

                    </div>
                </div>
                <br>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width smallTitle">空气干燥基基准：</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">空干基水分St,ad≤：</label>
                        <div class="layui-input-inline">
                            <input value="${p.kgj1!""}"  type="number"  min="0" name="kgj1" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">空干基全硫St,ad≤：</label>
                        <div class="layui-input-inline">
                            <input value="${p.kgj2!""}" type="number"  min="0" name="kgj2" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>

                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">空干基挥发分Vad：</label>
                        <div class="layui-input-inline">
                            <input value="${p.kgj31!""}" type="number"  min="0" name="kgj31" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）至</label>
                        <div class="layui-input-inline">
                            <input type="number" value="${p.kgj32!""}" lay-verify="biggerKgj" min="0" name="kgj32" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>

                    </div>
                </div>
                <br>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width smallTitle">干基基准：</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">干基高位发热量Qgr,d≥：</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry1!""}" type="number"  min="0" name="dry1" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（KCal/kg）</label>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">干基全硫St,d≤：</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry2!""}" type="number"  min="0" name="dry2" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">干燥无灰基挥发分：</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry31!""}" type="number"  min="0" name="dry31" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）至</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry32!""}" type="number" lay-verify="biggerDry" min="0" name="dry32" autocomplete="off" class="layui-input">
                        </div>
                        <label class="myLable">（%）</label>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">粒度(mm)≤：</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry4!""}" type="number"  min="0" name="dry4" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">灰熔点ST(℃)≥：</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry5!""}" type="number"  min="0" name="dry5" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label label-width">哈式可磨系数(HGI)≥：</label>
                        <div class="layui-input-inline">
                            <input value="${p.dry6!""}" type="number" min="0" name="dry6" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label label-width">备注：</label>
                    <div class="layui-input-block">
                        <textarea name="dry7" value="${p.dry7!""}" placeholder="请输入内容" class="layui-textarea area-width"></textarea>
                    </div>
                </div>
        </div>
        <br><br>

        <div style="text-align:center">
            <button type="submit" class="layui-btn layui-btn-radius layui-btn-primary" lay-submit lay-filter="savePR">保存</button>
             <button type="submit" class="layui-btn layui-btn-radius " lay-submit lay-filter="submitPR">提交</button>
        </div>
        </form>

    </div>
    <#include "/base/main-footer.ftl">
</div>

<script src="/static/lib/layui/layui.js"></script>
<script>
    layui.use(['layer', 'form', 'element', 'jquery','table'], function () {
        let layer = layui.layer, form = layui.form, $ = layui.jquery;
        form.on("radio(quote)", function (data) {
            let intput = $("#quote-input")
            if (data.value === "0"){
                intput.addClass("layui-disabled")
                intput.attr("disabled","true")
            }else {
                intput.removeClass("layui-disabled")
                intput.removeAttr("disabled")
            }
        });
        form.on("radio(per)", function (data) {
            let intput = $("#per-input")
            if (data.value === "0"){
                intput.addClass("layui-disabled")
                intput.attr("disabled","true")
            }else {
                intput.removeClass("layui-disabled")
                intput.removeAttr("disabled")
            }
        });

        form.verify({
            bjAfterApply: function(value, item){
                let eStr = $("input[name=createDate]").val()
                let endDate = new Date(eStr),jhDate = new Date(value)
                if (endDate.getTime() > jhDate.getTime()) {
                    return "报价截止日期必须在申请日期之后"
                }
            },
            bjBeforeJh: function(value, item){
                let eStr = $("input[name=jhtime]").val()
                let endDate = new Date(eStr),jhDate = new Date(value)
                if (endDate.getTime() < jhDate.getTime()) {
                    return "报价截止日期必须在交货开始时间之前"
                }
            },
            applyBeforeJh: function(value, item){
                let eStr = $("input[name=jhtime]").val()
                let endDate = new Date(eStr),jhDate = new Date(value)
                if (endDate.getTime() < jhDate.getTime()) {
                    return "申请日期必须在交货开始时间之前"
                }
            },
            jhnotBefore: function(value, item){
                let eStr = $("input[name=jhtimeEnd]").val()
                let endDate = new Date(eStr),jhDate = new Date(value)
                if (endDate.getTime() < jhDate.getTime()) {
                    return "交货结束时间必须在交货开始时间之前"
                }
            },
            biggerPrice: function (value) {
                let lessPrice = $("input[name=minLimitPrice]").val()
                if (parseInt(value) < parseInt(lessPrice)) {
                    return "最高限价必须大于等于最低限价"
                }
            },
            biggerRec: function (value) {
                let lessPrice = $("input[name=rec51]").val()
                if (parseInt(value) < parseInt(lessPrice)) {
                    return "最高收到基挥发分必须大于等于最低收到基挥发分"
                }
            },
            biggerKgj: function (value) {
                let lessPrice = $("input[name=kgj31]").val()
                if (parseInt(value) < parseInt(lessPrice)) {
                    return "最高空干基挥发分必须大于等于最低空干基挥发分"
                }
            },
            biggerDry: function (value) {
                let lessPrice = $("input[name=dry31]").val()
                if (parseInt(value) < parseInt(lessPrice)) {
                    return "最高干燥无灰基挥发分必须大于等于最低干燥无灰基挥发"
                }
            },
        });
        let loading = false
        form.on('submit(savePR)', function (data) {

            if (loading) {
                return false;
            }
            loading = true

            const res = Object.assign(data.field,{permitStatus:0})
            $.ajax({
                type: "POST",
                url: "/createPR.do",
                data: JSON.stringify(res) ,
                dataType: "json",
                contentType: 'application/json; charset=UTF-8',
                success: function (data) {
                    if (data.isSuccess){
                        layer.msg("创建成功")
                        setTimeout(function () {
                            loading = true
                            window.location = "/queryPR"
                        },2000)
                    } else {
                        loading = true
                        layer.msg(data.msg)
                    }
                }
            });
            return false;
        });

        form.on('submit(submitPR)', function (data) {
            if (loading) {
                return false;
            }
            const res = Object.assign(data.field,{permitStatus:1})
            loading = true
            $.ajax({
                type: "POST",
                url: "/createPR.do",
                data: JSON.stringify(res) ,
                dataType: "json",
                contentType: 'application/json; charset=UTF-8',
                    success: function (data) {
                        if (data.isSuccess){
                            layer.msg("创建成功")
                            setTimeout(function () {
                                loading = false
                                window.location = "/queryPR"
                            },2000)
                        } else {
                            loading = false
                            layer.msg(data.msg)
                        }
                    }
                });
            return false;
        });
    });
</script>
</body>
</html>